package cappuccino.couldbook.core.mananger;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;

import cappuccino.couldbook.App;

/**
 * Created by Administrator on 2016/9/7.
 */
public class AccountM {

    private static final String TAG = "AccountM";
    String type = "cappnuccino.couldbook";
    Context mContext;
    public AccountM(Context context){
        mContext = context;
    }
    public void saveAccount(int id){
        SharedPreferences.Editor editor = mContext.getSharedPreferences("user",Context.MODE_PRIVATE).edit();
        editor.clear();
        editor.putInt("userId",id);
        editor.commit();
        Log.v(TAG,"commit");
    }
    public void clearAccout(){
        SharedPreferences.Editor editor = mContext.getSharedPreferences("user",Context.MODE_PRIVATE).edit();
        editor.clear();
        editor.commit();
    }

    public int getAccout(){
        SharedPreferences read = mContext.getSharedPreferences("user",Context.MODE_PRIVATE);
        int userId =  read.getInt("userId",-1);
        Log.v(TAG,"userId:"+userId);
        return userId;
    }
}
